package ar.fi.uba.taller2.participacion.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

public class UsuariosXmlParser {

	public ArrayList<String> parseXml(InputStream in) {
		ArrayList<String> users = new ArrayList<String>();
		try {
			UsuarioParserHandler handler = new UsuarioParserHandler();
			XMLReader parser = XMLReaderFactory.createXMLReader();
			parser.setContentHandler(handler);
			InputSource source = new InputSource(in);

			parser.parse(source);
			users = handler.getUsers();

		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {

		}
		return users;
	}
}
